home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / PowerPlant / PP Balloon Help Support / Read me < prev   
Encoding:
Text File  |  1996-08-19  |  5.4 KB  |  64 lines  |  [TEXT/ttxt]

  1. PP Balloon Help Support (update)
  2.  
  3. Here are some classes which I use to provide Balloon Help for my PowerPlant based application. This provides balloon help for individual panes in windows or dialogs. This is an update from an early version of these classes and provides a number of new useful features:
  4.  
  5. (1) Balloon help can now be obtained in LDialogBox sub-classes.
  6. (2) Balloon help is now available for disabled items.
  7. (3) Balloon help can be context sensitive with different text for enabled or disabled panes and controls which are on or off.
  8. (4) Constructor custom types are now available for adding balloon help in Constructor rather than writing any code.
  9. (5) Performance improved - previously there was a delay when moving the cursor over an item with balloon help. Now the balloon appears much faster and copes better with the cursor being moved around quickly.
  10.  
  11. Basic principal
  12. The ‘AdjustCursor’ method of the LApplication and StDialogHandler classes is overridden to provide additional functionality. Now, whenever the cursor moves over a new pane, the ‘ExecuteAttachments’ method for the new pane is called with the message ‘msg_ShowHelp’. If the pane has a ‘CHelpAttach’ attachment and balloon help is on then a balloon is produced for that pane. The code takes care of tracking the current ‘help target pane’ and removing the balloon when the cursor moves out of the pane. Also if the state of the pane or control changes while the balloon is over the pane then the balloon help text may change depending on the type of attachment in use.
  13.  
  14. Using the main classes
  15.  
  16. Add ‘CBalloonApp.cp’, ‘CBalloonDialog.cp’ and ‘CHelpAttach.cp’ to your project.
  17.  
  18. Derive your application class from ‘CBalloonApp’ (make sure that you do not override the AdjustCursor method in your application class, or if you do make sure you call the inherited method).
  19.  
  20. To use balloons in a ‘LDialogBox’ sub-class use the ‘CBalloonDialog’ class in place of ‘StDialogHandler’.
  21.  
  22. Using the attachments
  23.  
  24. There are now three help attachment classes:
  25.  
  26. CHelpAttach  : provides a single ‘STR#’ index. The balloon is shown for enabled and disabled panes.
  27. CHelpPaneAttach  : provides two ‘STR#’ indexes. The first is used if the pane is enabled, the second is used if the pane is disabled.
  28. CHelpControlAttach  : provides three ‘STR#’ indexes. The first is used if the control is enabled and its value is not zero, the second is used if thecontrol is enabled and its value is zero, the third is used if the control is disabled and does not depend on the value. IMPORTANT This class must only be attached to sub-classes of ‘LControl’ as it type-casts its ioParam value to ‘LControl’. Failure to do this will almost certainly result in a crash.
  29.  
  30. There are two ways to use these attachments:
  31.  
  32. Add them programmatically :
  33.  
  34. Add a ‘CHelpAttach’ class or one of its sub-classes to each item in a window for which you want to provide balloon help. This is best done in the window’s ‘FinishCreateSelf’ method. When creating the ‘CHelpAttach’ you need to specify a ‘STR#’ resource id and the requisite number of indexes which are used to get the balloon's text.
  35.  
  36. eg 
  37.             LPane*     pane_with_help = FindPaneByID(paneid_MyPane);
  38.             pane_with_help->AddAttachment(new CHelpAttach(STRx_Balloons, str_PaneHelp));
  39.             LControl*     control_with_help = (LControl*) FindPaneByID(paneid_MyControl);
  40.             control_with_help->AddAttachment(new CHelpControlAttach(STRx_Balloons,
  41.                                                                                                                             str_ControlOnHelp,
  42.                                                                                                                             str_ControlOffHelp,
  43.                                                                                                                             str_ControlDisabledHelp));
  44.  
  45. Add them in Constructor :
  46.  
  47. The ‘HelpAttach.rsrc’ file contains three custom pane types for Constructor. To use these, copy them to your project’s Constructor file. The custom types will then appear in the ‘PowerPlant Display Classes’ list. To add a help attachment, use the ‘Show Hierarchy’ view and drag the appropriate attachment from the display list to the pane or control that requires a balloon. Then double-click the new attachment and set the STR# resource details (note that the ‘Execute Message’ value is irrelevant as the help attachments over ride this value to set the proper help message value).
  48.  
  49. At the moment one problem exists with this scheme - adding help to the default button in a dialog. The problem arises because the ‘LDialogBox’ class creates a ‘LDefaultOutline’ class which sits above the default button’s pane and is not accessible via Constructor. Thus the help attachment for the default button never gets executed as the default outline is the pane that is found in the ‘AdjustCursor’ methods. The only way round this is to programmatically add the help attachment to the default outline.
  50.  
  51. Notes
  52. If you wish to customise your help balloons (ie provide pictures or styled text in the balloon) then sub-class the ‘CHelpAttach’ classes and override the ‘FillHMRecord’ method.
  53.  
  54. If you have any comments, find any bugs or come up with any improvements then please let me know. Feel free to use this code in whatever way you like.
  55.  
  56. mail:      Cyrus Daboo,
  57.                64 Mulberry Close,
  58.                Cambridge  CB4 2AS.
  59.                UK.
  60.  
  61. phone:     +44 1223 328240
  62. e-mail:    cyrus.daboo@dial.pipex.com
  63. URL:       http://dialspace.dial.pipex.com/cydasoft
  64.